import { UserAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        cartTotal: 0,

        userInfo: {
            nickName: '滴滴',
            coin: 0,
            headImg: require('../../assets/img/service.848ec511.png')
        }
    },
    mutations: {
        updateUser(state, payloay) {
            state.cartTotal = payloay.cartTotal
            state.userInfo = payloay.userInfo
        },
        initUser(state) {
            state.cartTotal = 0,
                state.userInfo = {
                    nickName: '滴滴',
                    coin: 0,
                    headImg: require('../../assets/img/service.848ec511.png')
                }
        }
    },
    actions: {
        async asyupdateUser({ commit }, payloay) {
            let res = await UserAPI();
            // console.log('用户信息', res);
            commit('updateUser', res.data.data)

        }
    }
}